package cn.whr.server1.repository;

import cn.whr.server1.entity.UserEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public interface UserRepository extends JpaRepository<UserEntity, String> {

    @Modifying
    @Query(value = "update bs_t_user set pass_word=?1, status=?3 where pid=?2", nativeQuery = true)
    Integer updatePwdByPid(String pwd, String pid, String status);

    @Modifying
    @Query(value = "delete  from bs_t_user where name = ?2 and pid!=?1", nativeQuery = true)
    Integer deleteExceptPid(String pid, String name);

    @Query(value = "select * from bs_t_user u where u.name=?1", nativeQuery = true)
    UserEntity findRegisteredByName(String name);

}
